sgdk
vdp_bg.h File Reference

VDP background plan support. More...

#include "bmp.h"
#include "vdp.h"
#include "vdp_tile.h"

Go to the source code of this file.

Classes

struct  Image

Functions

void VDP_setHorizontalScroll (VDPPlan plan, s16 value)
 Set plan horizontal scroll (plain scroll mode).
3 horizontal scroll modes are supported:

void VDP_setHorizontalScrollTile (VDPPlan plan, u16 tile, s16 *values, u16 len, u16 use_dma)
 Set plan horizontal scroll (tile scroll mode).
3 horizontal scroll modes are supported:

void VDP_setHorizontalScrollLine (VDPPlan plan, u16 line, s16 *values, u16 len, u16 use_dma)
 Set plan horizontal scroll (line scroll mode).
3 horizontal scroll modes are supported:

void VDP_setVerticalScroll (VDPPlan plan, s16 value)
 Set plan vertical scroll (plain scroll mode). 2 vertical scroll modes are supported:

void VDP_setVerticalScrollTile (VDPPlan plan, u16 tile, s16 *values, u16 len, u16 use_dma)
 Set plan vertical scroll (2-Tiles scroll mode). 2 vertical scroll modes are supported:

void VDP_clearPlan (u16 plan, u8 use_dma)
 Clear specified plan.
VDPPlan VDP_getTextPlan ()
 Returns the plan used to display text.
u16 VDP_getTextPalette ()
 Returns the palette number used to display text.
u16 VDP_getTextPriority ()
 Returns the priority used to display text.
void VDP_setTextPlan (VDPPlan plan)
 Define the plan to use to display text.
void VDP_setTextPalette (u16 palette)
 Define the palette to use to display text.
void VDP_setTextPriority (u16 prio)
 Define the priority to use to display text.
void VDP_drawText (const char *str, u16 x, u16 y)
 Draw text.
void VDP_clearText (u16 x, u16 y, u16 w)
 Clear text.
void VDP_clearTextLine (u16 y)
 Clear a complete line of text.
void VDP_drawTextBG (u16 plan, const char *str, u16 flags, u16 x, u16 y)
 Draw text in backgound plan.
void VDP_clearTextBG (u16 plan, u16 x, u16 y, u16 w)
 Clear text from background plan.
void VDP_clearTextLineBG (u16 plan, u16 y)
 Clear a complete line of text from background plan.
u16 VDP_drawBitmap (u16 plan, const Bitmap *bitmap, u16 x, u16 y)
 Draw Bitmap in specified background plan and at given position.
u16 VDP_drawBitmapEx (u16 plan, const Bitmap *bitmap, u16 basetile, u16 x, u16 y, u16 loadpal)
 Draw Bitmap in specified background plan and at given position.
u16 VDP_drawImage (u16 plan, const Image *image, u16 x, u16 y)
 Draw Map in specified background plan and at given position.
u16 VDP_drawImageEx (u16 plan, const Image *image, u16 basetile, u16 x, u16 y, u16 loadpal, u16 use_dma)
 Draw Map at the specified plan position.

Variables

u16 curTileInd

Detailed Description

VDP background plan support.

Author:
Stephane Dallongeville
Date:
08/2011

This unit provides plan A & plan B facilities :

  • set scrolling
  • clear plan
  • draw text in plan

Function Documentation

void VDP_clearPlan ( u16  plan,
u8  use_dma 
)

Clear specified plan.

Parameters:
planPlan we want to clear.
Accepted values are:
  • VDP_PLAN_A
  • VDP_PLAN_B
use_dmaUse DMA or software clear.

Using DMA permit faster clear operation but can lock Z80 execution.

void VDP_clearText ( u16  x,
u16  y,
u16  w 
)

Clear text.

Parameters:
xX position (in tile).
yy position (in tile).
wwidth to clear (in tile).

This method uses VDP_PLAN_A to draw/clear the text.

void VDP_clearTextBG ( u16  plan,
u16  x,
u16  y,
u16  w 
)

Clear text from background plan.

Parameters:
planPlan where we want to clear text.
Accepted values are:
  • VDP_PLAN_A
  • VDP_PLAN_B
xX position (in tile).
yy position (in tile).
wwidth to clear (in tile).
void VDP_clearTextLine ( u16  y)

Clear a complete line of text.

Parameters:
yy position (in tile).

This method uses VDP_PLAN_A to draw/clear the text.

void VDP_clearTextLineBG ( u16  plan,
u16  y 
)

Clear a complete line of text from background plan.

Parameters:
planPlan where we want to clear text.
Accepted values are:
  • VDP_PLAN_A
  • VDP_PLAN_B
yy position (in tile).
u16 VDP_drawBitmap ( u16  plan,
const Bitmap bitmap,
u16  x,
u16  y 
)

Draw Bitmap in specified background plan and at given position.

Parameters:
planPlan where we want to draw the bitmap.
Accepted values are:
  • VDP_PLAN_A
  • VDP_PLAN_B
bitmapGenesis bitmap (the width and height should be aligned to 8).
The Bitmap is unpacked "on the fly" if needed (require some memory).
xPlan X position (in tile).
yPlan Y position (in tile).
Returns:
FALSE if there is not enough memory to unpack the specified Bitmap (only if compression was enabled).

This function does "on the fly" 4bpp bitmap conversion to tile data and transfert them to VRAM.
It's very helpful when you use bitmap images but the conversion eats sometime so you should use it only for static screen only.
For "in-game" condition you should use VDP_loadTileData() method with prepared tile data.

See also:
VDP_loadBMPTileData()
u16 VDP_drawBitmapEx ( u16  plan,
const Bitmap bitmap,
u16  basetile,
u16  x,
u16  y,
u16  loadpal 
)

Draw Bitmap in specified background plan and at given position.

Parameters:
planPlan where we want to draw the bitmap.
Accepted values are:
  • VDP_PLAN_A
  • VDP_PLAN_B
bitmapGenesis bitmap (the width and height should be aligned to 8).
The Bitmap is unpacked "on the fly" if needed (require some memory).
basetileBase tile attributes data (see TILE_ATTR_FULL() macro).
xPlan X position (in tile).
yPlan Y position (in tile).
loadpalLoad the bitmap palette information when non zero.
Returns:
FALSE if there is not enough memory to unpack the specified Bitmap (only if compression was enabled).

This function does "on the fly" 4bpp bitmap conversion to tile data and transfert them to VRAM.
It's very helpful when you use bitmap images but the conversion eats sometime so you should use it only for static screen only.
For "in-game" condition you should use VDP_loadTileData() method with prepared tile data.

See also:
VDP_loadBMPTileData()
u16 VDP_drawImage ( u16  plan,
const Image image,
u16  x,
u16  y 
)

Draw Map in specified background plan and at given position.

Parameters:
planPlan where we want to draw the map.
Accepted values are:
  • VDP_PLAN_A
  • VDP_PLAN_B
imageImage structure to draw.
The Image is unpacked "on the fly" if needed (require some memory).
xPlan X position (in tile).
yPlan Y position (in tile).
Returns:
FALSE if there is not enough memory to unpack the specified Image (only if compression was enabled).

Load the image tiles data in VRAM and display it at specified tilemap region.

See also:
VDP_drawImageEx()
u16 VDP_drawImageEx ( u16  plan,
const Image image,
u16  basetile,
u16  x,
u16  y,
u16  loadpal,
u16  use_dma 
)

Draw Map at the specified plan position.

Parameters:
planPlan where we want to load map.
Accepted values are:
  • VDP_PLAN_A
  • VDP_PLAN_B
imageImage structure to draw.
The Image is unpacked "on the fly" if needed (require some memory).
basetileBase tile attributes data (see TILE_ATTR_FULL() macro).
xPlan X position (in tile).
yPlan Y position (in tile).
loadpalLoad the bitmap palette information when non zero. Accepted values are:
0 = don't load palette.
1 = HIGH PRIORITY TILE.
0:
use_dmaUse DMA transfert (faster but can lock Z80 execution).
Returns:
FALSE if there is not enough memory to unpack the specified Image (only if compression was enabled).

Load the image tiles data in VRAM and display it at specified tilemap region.

See also:
VDP_drawImage()
void VDP_drawText ( const char *  str,
u16  x,
u16  y 
)

Draw text.

Parameters:
strString to draw.
xX position (in tile).
yy position (in tile).

This method uses VDP_PLAN_A to draw the text.
See VDP_setTextPalette() and VDP_setTextPriority().

void VDP_drawTextBG ( u16  plan,
const char *  str,
u16  flags,
u16  x,
u16  y 
)

Draw text in backgound plan.

Parameters:
planPlan we want to use to draw text.
Accepted values are:
  • VDP_PLAN_A
  • VDP_PLAN_B
strString to draw.
flagstile flags (see TILE_ATTR macro).
xX position (in tile).
yy position (in tile).

This method uses the specified plan to draw the text.
Each character fit in one tile (8x8 pixels).

u16 VDP_getTextPalette ( )

Returns the palette number used to display text.

See also:
VDP_drawText(..)
VDP_clearText(..)
VDPPlan VDP_getTextPlan ( )

Returns the plan used to display text.

Returned value should be either PLAN_A or PLAN_B.

See also:
VDP_drawText(..)
VDP_clearText(..)
u16 VDP_getTextPriority ( )

Returns the priority used to display text.

See also:
VDP_drawText(..)
VDP_clearText(..)
void VDP_setHorizontalScroll ( VDPPlan  plan,
s16  value 
)

Set plan horizontal scroll (plain scroll mode).
3 horizontal scroll modes are supported:

  • Plain (whole plan)
  • Tile (8 pixels bloc)
  • Line (per pixel scroll)
Parameters:
planPlan we want to set the horizontal scroll.
Accepted values are:
  • PLAN_A
  • PLAN_B
valueH scroll offset.
Negative value will move the plan to the left while positive value will move it to the right.
See also:
VDP_setScrollingMode() function to change scroll mode.
void VDP_setHorizontalScrollLine ( VDPPlan  plan,
u16  line,
s16 *  values,
u16  len,
u16  use_dma 
)

Set plan horizontal scroll (line scroll mode).
3 horizontal scroll modes are supported:

  • Plain (whole plan)
  • Tile (8 pixels bloc)
  • Line (per pixel scroll)
Parameters:
planPlan we want to set the horizontal scroll.
Accepted values are:
  • PLAN_A
  • PLAN_B
lineFirst line we want to set the horizontal scroll.
valuesH scroll offsets.
Negative values will move the plan to the left while positive values will move it to the right.
lenNumber of line to set.
use_dmaUse DMA flag (faster for large transfer).
See also:
VDP_setScrollingMode()
void VDP_setHorizontalScrollTile ( VDPPlan  plan,
u16  tile,
s16 *  values,
u16  len,
u16  use_dma 
)

Set plan horizontal scroll (tile scroll mode).
3 horizontal scroll modes are supported:

  • Plain (whole plan)
  • Tile (8 pixels bloc)
  • Line (per pixel scroll)
Parameters:
planPlan we want to set the horizontal scroll.
Accepted values are:
  • PLAN_A
  • PLAN_B
tileFirst tile we want to set the horizontal scroll.
valuesH scroll offsets.
Negative values will move the plan to the left while positive values will move it to the right.
lenNumber of tile to set.
use_dmaUse DMA flag (faster for large transfer).
See also:
VDP_setScrollingMode() function to change scroll mode.
void VDP_setTextPalette ( u16  palette)

Define the palette to use to display text.

Parameters:
palettePalette number.
See also:
VDP_drawText(..)
VDP_clearText(..)
void VDP_setTextPlan ( VDPPlan  plan)

Define the plan to use to display text.

Parameters:
planPlan where to display text.
Accepted values are:
PLAN_A
PLAN_B
See also:
VDP_drawText(..)
VDP_clearText(..)
void VDP_setTextPriority ( u16  prio)

Define the priority to use to display text.

Parameters:
prioPriority:
1 = HIGH PRIORITY TILE.
0 = LOW PRIORITY TILE.
See also:
VDP_drawText(..)
VDP_clearText(..)
void VDP_setVerticalScroll ( VDPPlan  plan,
s16  value 
)

Set plan vertical scroll (plain scroll mode). 2 vertical scroll modes are supported:

  • Plain (whole plan)
  • 2-Tiles (16 pixels bloc)
Parameters:
planPlan we want to set the vertical scroll.
Accepted values are:
  • PLAN_A
  • PLAN_B
valueV scroll offset.
Negative value will move the plan down while positive value will move it up.
See also:
VDP_setScrollingMode()
void VDP_setVerticalScrollTile ( VDPPlan  plan,
u16  tile,
s16 *  values,
u16  len,
u16  use_dma 
)

Set plan vertical scroll (2-Tiles scroll mode). 2 vertical scroll modes are supported:

  • Plain (whole plan)
  • 2-Tiles (16 pixels bloc)
Parameters:
planPlan we want to set the vertical scroll.
Accepted values are:
  • PLAN_A
  • PLAN_B
tileFirst tile we want to set the vertical scroll.
valuesV scroll offsets.
Negative values will move the plan down while positive values will move it up.
lenNumber of tile to set.
use_dmaUse DMA flag (faster for large transfer).
See also:
VDP_setScrollingMode()

Variable Documentation

Contains current VRAM tile position where we will upload next tile data.

See also:
VDP_drawBitmap()
VDP_drawImage()
 All Classes Files Functions Variables Typedefs Enumerations Defines